<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>自然人银行账号信息管理</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>

<body class="iframeBody">
    <div class="Wrapper">
    	<div class="searchArea">
	    <form id="cst_bank_mgt_form_id">
	        <div class="fieldset1 clearFix">
		            <div class="fieldBox">
		                <div class="label" style="width: 60px;">客户名称</div>
		                <div class="field">
		                    <input name="cstNm" id="cstNm" type="text" class="ui-textbox" value="" ligerui="width: 160">
		                </div>
		            </div>
		            <div class="fieldBox">
		                <div class="label" style="width: 60px;">开户银行</div>
		                <div class="field">
		                    <select name="bkCd" id="bkCd" ligerui="width: 160">
		                        <option value=" " seleted>请选择</option>
		                       <c:forEach items="${searchSelectBkCdList }" var="bkcditem">
		                        	<option value="${bkcditem.key }">${bkcditem.value }</option>
		                        </c:forEach>
		                    </select>
		                </div>
		            </div>
		            <div class="fieldBox">
		                <div class="label" style="width: 60px;">开户机构</div>
		                <div class="field">
		                    <input name="accOrgNm" id="accOrgNm" type="text" class="ui-textbox" value="" ligerui="width: 160">
		                </div>
		            </div>
		            <div class="fieldBox">
		                <div class="label" style="width: 60px;">开户名称</div>
		                <div class="field">
		                    <input name="accNm" id="accNm" type="text" class="ui-textbox" value="" ligerui="width: 160">
		                </div>
		            </div>
		            <div class="fieldBox">
		                <div class="label" style="width: 60px;">银行帐号</div>
		                <div class="field">
		                    <input name="accNo" id="accNo" type="text" class="ui-textbox" value="" ligerui="width: 160">
		                </div>
		            </div>
		            <div class="fieldBox">
		                <div class="label" style="width: 60px;">开户证件号</div>
		                <div class="field">
		                    <input name="certNo" id="certNo" type="text" class="ui-textbox" value="" ligerui="width: 160">
		                </div>
		            </div>
		            <div class="fieldBox">
		                <div class="label" style="width: 60px;">所属机构</div>
		                <div class="field">
		                    <select name="buOrgCd" id="buOrgCd" ligerui="width: 160">
		                        <option value=" " seleted>请选择</option>
		                        <c:forEach items="${orgListList }" var="org">
		                        	<c:if test="${currentBuOrgCd == org.key }">
		                        		<option value="${org.key }" selected>${org.value }</option>
		                        	</c:if>
		                        	<c:if test="${currentBuOrgCd != org.key }">
		                        		<option value="${org.key }">${org.value }</option>
		                        	</c:if>
		                        </c:forEach>
		                    </select>
		                </div>
	            	</div>
	            	
		            <div class="fieldBox">
		                <div class="label" style="width: 60px;">验证状态</div>
		                <div class="field">
		                    <select name="audStsCd" id="audStsCd" ligerui="width: 160">
		                        <option value=" " seleted>请选择</option>
		                        <c:forEach items="${validStsList }" var="org">
		                        	<c:if test="${currentBuOrgCd == org.key }">
		                        		<option value="${org.key }" selected>${org.value }</option>
		                        	</c:if>
		                        	<c:if test="${currentBuOrgCd != org.key }">
		                        		<option value="${org.key }">${org.value }</option>
		                        	</c:if>
		                        </c:forEach>
		                    </select>
		                </div>
	            	</div>
	            	
		            <div class="fieldBox">
		                <div class="label" style="width: 60px;">是否有效</div>
		                <div class="field">
		                    <select name="isValid" id="isValid" ligerui="width: 160">
		                        <option value=" " seleted>请选择</option>
		                        <c:forEach items="${yNList }" var="org">
		                        	<c:if test="${currentBuOrgCd == org.key }">
		                        		<option value="${org.key }" selected>${org.value }</option>
		                        	</c:if>
		                        	<c:if test="${currentBuOrgCd != org.key }">
		                        		<option value="${org.key }">${org.value }</option>
		                        	</c:if>
		                        </c:forEach>
		                    </select>
		                </div>
	            	</div>
	            	
                <div class="fieldBox">
		                <div class="label" style="width: 60px;">开始时间</div>
		                <div class="field">
		                    <input ligerui="width: 165" name="startDt" id="startDt" type="text" class="ui-datepicker" value="" >
		                </div>
		        </div>
                <div class="fieldBox">
		                <div class="label" style="width: 60px;">结束时间</div>
		                <div class="field">
		                    <input ligerui="width: 165" name="endDt" id="endDt" type="text" class="ui-datepicker" value="">
		                </div>
		        </div>                
	            		            		            	
	           	<div class="clearFix"></div>
			    <div class="btnsBox formBtns notRight">
			        <span id="searchBtn" onclick="searchBtnEvent();" class="sq-button-round">查询</span>
			        <span id="clearBtn" onclick="clearBtnEvent();" class="sq-button-round">清空</span>
			        <input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
			        <span id="downBtn" onclick="downloadBtnEvent();" class="sq-button-round">导出</span>
			        <!-- <span style="color: red;">只导出未验证通过的数据</span> -->
			    </div>
			    
			    <div class="clearFix"></div>
                <div class="fieldBox">
                    <div class="label"></div>
                    <div class="field">
                        <jsp:include page="../../system/sysUlFilesRec/sysSysUlFilesRecUpload.jsp" flush="true" >
                            <jsp:param name="fileNum" value="1"/>
                            <jsp:param name="filePath" value="customer/temp/"/>
                        </jsp:include>
                    </div>
                    <div class="field formBtns">
                    	<span id="upBtn" onclick="uploadBtnEvent();" class="sq-button-round">导入</span>
                    </div>
                </div>
	        </div>
	   </form>
    </div>
     <div class="sqPanel_body">
                <div id="ligergrid_bankacc" class="sq-grid"></div>
     </div>
       <!--  <div class="sqPanel">
            <div class="sqPanel_head inL">
                <div class="btnsBox inLC">
                    <span id="cust_cst_np_bank_acc_add_btn_id" class="sq-button sq-button-round">添加</span>
                </div>
                <span>银行账号</span>
            </div>
           
        </div> -->
    </div>
 	<!-- hide data 
	<div class="fieldBox col_100" style="display:none;">
		<div class="field">
		    <input name=cstId id="cstId" type="text" class="ui-textbox" value="${cstId}">
		</div>
	</div>-->
    
	<!-- 验证审核状态窗口-->
	<div id="div_bank_aud_sts_cd_id" style="display:none">
		<form id="div_bank_aud_sts_cd_id_form">
            <div class="fieldset1 tabel_col tabel_col_s clearFix noBorder">
			    <div class="fieldBox col_50">
			         <div class="label">验证状态</div>
			         <div class="field">
			               <select ligerui="width:120" name="validSts" id="win_bank_valid_sts_id" data-value="" validate="{required:true, select: true}">
		                        <c:forEach items="${validStsList }" var="vs" begin="0" step="1" varStatus="status">
				                     <c:if test="${status.index == 0}">
										 <option value="${vs.key }" selected>${vs.value }</option>
									 </c:if>
									 <c:if test="${status.index != 0}">
										 <option value="${vs.key }" >${vs.value }</option>
									 </c:if>
		                        </c:forEach>
		                    </select>
			              <span class="requiredSymbol">*</span>
			         </div>
			   </div>
			 <div class="fieldBox col_100">
			      <div class="label">备注</div>
			      <div class="field">
			          <textarea name="accRem" id="accRem" rows="4" class="l-textarea" style="width:99%" validate="{maxlength:150}"></textarea>
			      </div>
			 </div>
			 </div>
        </form>
	</div>
	
	<!-- 验证是否有效窗口-->
	<div id="div_bank_is_valid_id" style="display:none">
		<form id="div_bank_is_valid_form">
            <div class="fieldset1 tabel_col tabel_col_s clearFix noBorder">
			    <div class="fieldBox col_50">
			         <div class="label">是否有效</div>
			         <div class="field">
			               <select ligerui="width:120" name="isValid" id="win_bank_is_valid_id" data-value="" validate="{required:true, select: true}">
		                        <c:forEach items="${yNList }" var="yn" begin="0" step="1" varStatus="status">
				                     <c:if test="${status.index == 0}">
										 <option value="${yn.key }" selected>${yn.value }</option>
									 </c:if>
									 <c:if test="${status.index != 0}">
										 <option value="${yn.key }" >${yn.value }</option>
									 </c:if>
		                        </c:forEach>
		                    </select>
			              <span class="requiredSymbol">*</span>
			         </div>
			   </div>
			 </div>
        </form>
	</div>

    <script>
    $(function() {
    	initForm();
    	initGrid();
        initEvent();
    });
    
    //初始化Form
    function initForm(){
		$("#cst_bank_mgt_form_id").ligerForm({
        	 validate: true
 		});
		$("#div_bank_aud_sts_cd_id_form").ligerForm({
         	 validate: true
  		});
		
		$("#div_bank_is_valid_form").ligerForm({
        	 validate: true
 		});
    }
    
	//查询按钮事件
	function searchBtnEvent(){
	    var form = new liger.get("cst_bank_mgt_form_id");
	    var data = form.getData();
	    for (name in data){
	       cstBankGrid.setParm(name,data[name]);
	    };
	    cstBankGrid.reload();
	}
	
	//清空按钮事件
	function clearBtnEvent(){
		        $("#resetBtn").click();  //重置 input-text
		        var form = liger.get("cst_bank_mgt_form_id");
		        form.setData({  //重置select等特殊表单
		            "bkCd":" ",
		            "buOrgCd":" "
		        });
	}
    
    //初始化列表
    function initGrid(){
    	var _cstId = $("#cstId").val();

        $("#ligergrid_bankacc").ligerGrid({
            usePager: true,
            url: "<%=path%>/customer/cstbank/initMgeList.do",
            method : 'get',
            columns: [{
                display: '所属客户',
                name: 'cstNm',
                width: 150,
                align:'left',
                isSort:false
            },{
                display: '开户银行',
                name: 'bkCdNm',
                width: 150,
                align:'left',
                isSort:false
            }, {
                display: '开户机构',
                name: 'accOrgNm',
                width: 150,
                align:'left',
                isSort:false
            }, {
                display: '开户名称',
                name: 'accNm',
                minWidth: 150,
                align:'left',
                isSort:false,
                render: function (rowdata, rowindex, value, column) { 
            		var h = '';
        		    h='<a  href="javascript:showDetail(';
                    h+="'"+rowdata.id+"'";
                    h+=')">'+value+'</a>'
                    return h;
        		}
            }, {
                display: '银行账号',
                name: 'accNo',
                minWidth: 150,
                align:'left',
                isSort:false
            }, {
                display: '账户类型',
                name: 'accTypCdNm',
                minWidth: 100,
                isSort:false
            }, {
                display: '开户证件类型',
                name: 'certTypCdNm',
                width: 100,
                isSort:false
            }, {
                display: '证件号',
                name: 'certNo',
                minWidth: 150,
                align:'left',
                isSort:false
            }, {
                display: '是否代扣卡',
                name: 'isDeductNm',
                width: 70,
                isSort:false
            }, {
                display: '验证状态',
                name: 'audStsCdNm',
                width: 120,
                isSort:false,
                render: function (rowdata, rowindex, value){
                	if(StringUtils.isNotEmpty(rowdata.audStsCdRem)){
                		value = value + "("+rowdata.audStsCdRem+")";
                	}
                	return UIUtils.showColumnTip(value);
                }
            }, {
                display: '是否有效',
                name: 'isValidNm',
                width: 80,
                isSort:false
                
            },getGridOperColumnContent7(),
            getGridOperColumnContent8(),
            getGridOperColumnContent9(), {
                display: '备注',
                name: 'accRem',
                width: 200,
                render: function (rowdata, rowindex, value){
                    return UIUtils.showColumnTip(value);
                },
                isSort:false

            },getGridOperColumnContent()],
            width: '100%',
            //isScroll: false,
            height:'100%',
			heightDiff:-2,
            root:'rows',
	        record:'total',
            rownumbers: true,
            fixedCellHeight: false,
            usePagerOnLessPagesize: true,
            onAfterShowData: function(currentData) {
                SetIframe_height();
                $(".liger_tip").ligerTip();
            }
        });

        cstBankGrid = liger.get("ligergrid_bankacc");
        cstBankGrid.setHeight(100);
        cstBankGrid.options.isSingleCheck=true;
    }
    
    function getGridOperColumnContent7(){
    	return {
            display: '帐号来源',
            name: 'regWayCdNm',
            minWidth: 120,
            align:'left'
        };    	
    }
    
	function getGridOperColumnContent8(){
    	return {
            display: '签约号',
            name: 'signNo',
            minWidth: 120,
            align:'left'
        };    	
    }
    
	function getGridOperColumnContent9(){
    	return {
            display: '银行卡类型',
            name: 'cardTypeNm',
            minWidth: 120,
            align:'left'
        };		
	}
    
    //初始化事件
    function initEvent(){
    	
    }
    
  	//验证事件
	function validAudStsCdRow(_id, _bkCd) {
    	//如果客户ID不存在是不能修改
		/* if(_bkCd == CustomerConstant.CST_BK_CD_POST){
			UIUtils.alertWarning(LogUtils.LOG_CUST_NO_VALID_CARD);
			return;
		} */
		//每次加载钱清空前次
		$("#accRem").val("");
		
        $.ligerDialog.SQopen({
            width: 800,
            height:200,
            top: 100,
            title : '修改',
            target: $("#div_bank_aud_sts_cd_id"),
            buttons: [
                      {
                          text: "确定", cls: 'l-dialog-btn-ok', onclick:function(){
                          	modifyAudStsCd(_id, _bkCd);
                          }
                      }, {
                          text: "取消", cls: 'l-dialog-btn-no', onclick:function(){
                          	$.ligerDialog.hide();
                          }
                      }
                  ]

        });
	}
  	
    //修改审核状态
    function modifyAudStsCd(_id, _bkCd){
    	 var ligerForm = liger.get("div_bank_aud_sts_cd_id_form");
    	 var data = ligerForm.getData();
    	 var _url = "<%=path%>/customer/cstbank/modifyAudStsCd.do";
    	 data["id"] = _id;
    	 data["bkCd"] = _bkCd;
    	 AjaxUtils.ajaxPost(_url, data, function(data){
    		 if(data.success == 1){
    	    		$.ligerDialog.hide();
    	    		UIUtils.alertSuccess(data.info);
    	    		reloadGrid();
    			 }else{
    				UIUtils.alertError(data.info);
    			 }
    	 });
    }
    
  	//审核事件
	function validIsValidRow(_id, _isValid) {
		var form = liger.get("div_bank_is_valid_form");
        form.setData({  //重置select等特殊表单
            "isValid":_isValid
        });
        $.ligerDialog.SQopen({
            width: 600,
            height:110,
            top: 100,
            title : '修改',
            target: $("#div_bank_is_valid_id"),
            buttons: [
                      {
                          text: "确定", cls: 'l-dialog-btn-ok', onclick:function(){
                          	modifyIsValid(_id, _isValid);
                          }
                      }, {
                          text: "取消", cls: 'l-dialog-btn-no', onclick:function(){
                          	$.ligerDialog.hide();
                          }
                      }
                  ]

        });
	}
  	
    //修改是否显示状态
    function modifyIsValid(_id, _isValid){
    	 var ligerForm = liger.get("div_bank_is_valid_form");
    	 var data = ligerForm.getData();
    	 var _url = "<%=path%>/customer/cstbank/modifyIsValid.do";
    	 data["id"] = _id;
    	 AjaxUtils.ajaxPost(_url, data, function(data){
    		 if(data.success == 1){
    	    		$.ligerDialog.hide();
    	    		UIUtils.alertSuccess(data.info);
    	    		reloadGrid();
    			 }else{
    				UIUtils.alertError(data.info);
    			 }
    	 });
    }
    
    //查看详情
    function showDetail(_id){
    	$.ligerDialog.open({
            width: 800,
            height:220,
            title : '银行账号',
            url:'<%=path%>/customer/cstbank/toDetailPage.do?cbId='+_id,
            // 自定义buttons的时候 不要设置 fixButtons: true
            buttons: [{
                    text: "关闭", type: 'cancel',
                    onclick: function (item, Dialog) {
                        //在子页面里绑定 frameElement.dialog.onCancel = function () {}
                        if (Dialog.onCancel) Dialog.onCancel();
                    }
                }
            ]
        });
    }
    
    //获取Grid操作列内容
    function getGridOperColumnContent(){
    	 var data = {
            display: '操作',
            isSort: false,
            width: 160,
            align:'left',
            render: function (rowdata, rowindex, value){
                var h="";
                if(rowdata.regWayCd != '11003') {
                    //if(rowdata.bkCd != CustomerConstant.CST_BK_CD_POST){
                    h += '<a class="sq-button-hasicon" alt="验证" href="javascript:validAudStsCdRow(';
                    h += "'" + rowdata.id + "'";
                    h += ",'" + rowdata.bkCd + "'";
                    h += ",'ligergrid_bankacc'";
                    h += ")\"><i class=\"sqBtnIco_38\"></i>" + LogUtils.LOG_CMM_GRID_BTN_VALID + "</a>"

                    h += '<a class="sq-button-hasicon" alt="是否有效设置" href="javascript:validIsValidRow(';
                    h += "'" + rowdata.id + "'";
                    h += ",'" + rowdata.isValid + "'";
                    h += ")\"><i class=\"sqBtnIco_30\"></i>是否有效设置</a>"
                    //}
                }
                return h;
            }
    	 }
    	return data;
    }
    
    //下载
    function downloadBtnEvent(){
    	var form = liger.get("cst_bank_mgt_form_id");
        var data = form.getData();
        var parms="";
        for (name in data) {
	         if(data[name]){
	        	 parms+=name+"="+data[name]+"&";
	         }
        }
        if(StringUtils.isNotEmpty(parms) && parms.endsWith("&")){
	        parms = parms.substring(0,parms.length-1);
        }
        window.location.href="<%=path%>/customer/cstbank/downList.do?"+parms;
    }
    
    //上传
    function uploadBtnEvent(){
    	 //获取上传文件地址
        var files=getUploadResultParams();
        if(files && files.length > 0){
            var filePath=files[0].filePath;
            var fileExtension = filePath.substring(filePath.lastIndexOf('.') + 1);
            if(fileExtension!='xls'&&fileExtension!='XLS'){
                UIUtils.alertWarning("请上传.xls后缀的文件!");
                return;
            }
            
            var _url = '<%=path%>/customer/cstbank/importBank.do';
            AjaxUtils.ajaxPost(_url, {filePath:filePath}, function(msg){
            	if(msg.success == 1){
            		UIUtils.alertSuccess(msg.info);
        		 }else{
        			UIUtils.alertErrorHold1(msg.info);
        		 }
            }, true);
        }else{
            UIUtils.alertWarning("请先上传导入文件!");
        }
    }
    
    //重新刷新GRID
    function reloadGrid(){
    	var form = new liger.get("cst_bank_mgt_form_id");
        var data = form.getData();
        for (name in data){
        	cstBankGrid.setParm(name,data[name]);
        };
        cstBankGrid.reload();
    }
    
    </script>
</body>

</html>
